package com.biz.primus.ms.coupon.dao.po;

import com.biz.primus.model.coupon.enums.CouponAcquireApproach;
import com.biz.primus.model.coupon.enums.CouponState;
import com.biz.primus.ms.base.jpa.po.BaseEntity;
import java.time.LocalDateTime;
import javax.persistence.*;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/**
 * 优惠券
 *
 * @author david-liu
 */
@Getter
@Setter
@NoArgsConstructor
@Entity
@Table(name = "cpn_coupon", indexes = {
        @Index(name = "cpn_userId_idx", columnList = "memberId")
})
public class Coupon extends BaseEntity {
    private static final long serialVersionUID = -4481570210261134503L;

    // 优惠券归属的会员Id
    @Column(nullable = false)
    private Long userId;

    // 优惠券归属的优惠券类型
    @ManyToOne(fetch = FetchType.LAZY)
    private CouponType couponType;

    // 优惠券状态
    @Enumerated(value = EnumType.STRING)
    private CouponState couponState;

    // 优惠券是否被使用了
    @Column
    private Boolean used = false;

    // 优惠券使用的时间
    @Column
    private LocalDateTime useTime;

    // 优惠券领取时间
    @Column
    private LocalDateTime receivedTime;

    // 优惠券获取方式
    @Enumerated(value = EnumType.STRING)
    private CouponAcquireApproach couponAcquireApproach;
}

